import argparse

from app.rag.internal.server import ragserver
from app.rag.internal.svc import svc
from app.rag.internal.config import config
from common.utils import conf, logger, tracing


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--config", "-f", default="etc/rag.yaml")
    args = parser.parse_args()

    c = conf.must_load_config(config.Config, args.config)
    logger.setup_logger(c.log.path)
    tracing.init_telemetry(c.telemetry_conf)

    svcCtx = svc.ServiceContext(c)
    ragserver.serve(svcCtx)